$(function(){


    // 根据不同的车型，显示不同的价格
    $(function () {
        $("#carFor").click(function () {
            let value = $("#carFor option:selected").val();
            for (var i = 0; i < obj.length; i++) {
                if (value === obj[i].auto.model) {
                    let autoId = obj[i].auto.autoId;
                    let carId = GetQueryString("id");
                    $.ajax({
                        type: "GET",
                        url: "/Views/querySpencer",
                        data: {autoId: autoId, carId: carId},
                        dataType: "json",
                        success: function (data) {
                            let str = "";
                            if (data.length===0){
                                let li = '<li>'+
                                    '<p>暂无商家</p>'+
                                    '</li>';
                                $('#spencerName').html(li)
                            }else {
                                for (let j = 0; j < data.length; j++) {
                                    str += '<li>\n' +
                                        '                        <input class="check" type="radio" name="address" value="' + data[j].spencerName + '">' + data[j].spencerName + '\n' +
                                        '                        <p><i class="fa fa-map-marker" aria-hidden="true"></i>地址:\n' +
                                        '                            <span>\n' +
                                        '                                ' + data[j].location + '\n' +
                                        '                            </span>\n' +
                                        '                            </p>\n' +
                                        '                    </li>'
                                }
                                $('#spencerName').html(str)
                            }
                        }
                    })
                    $('.zdPrice').html('价格: ￥' + obj[i].auto.price);
                    $("#autoImg").prop('src', '/assets/images/auto/' + obj[i].auto.picture);
                }
            }
        })
    })
})

